<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>解构赋值</title>
</head>
<body>

</body>

<script>
    //传统的赋值
    var a =1, b=2, c=3;
    console.log(a,b,c) //1 2 3

    //数组的解构
    var [x,y,z] = [7,8,9];
    console.log(x,y,z);//7 8 9

    //对象的赋值
    var user = {name:"张三", age:18,address:"北京"};
    //传统的对象属性赋值
    var username = user.name;
    var userage= user.age;
    var useraddress= user.address;
    console.log(username, userage, useraddress);//张三 18 北京

    //ES6的对象解构赋值{对象的属性}
    var {name,age,address} = user;
   // var {address} = user; //var address =user.address
    console.log(name,age,address);
</script>
</html>